<?php

namespace App\ModelFilters;

use EloquentFilter\ModelFilter;

class QHSchoolPlanFilter extends ModelFilter
{
    /**
    * Related Models that have ModelFilters as well as the method on the ModelFilter
    * As [relationMethod => [input_key1, input_key2]].
    *
    * @var array
    */
    public $relations = [];

    public function key($v) {
        return $this->whereHas('school', function ($q) use ($v) {
            $q->where('name', 'like', '%'.$v.'%');
        })->orWhereHas('spec', function ($q) use ($v) {
            $q->where('name', 'like', '%'.$v.'%')->orWhere('code', $v);
        });
    }
}
